// pages/successInfo/successInfo.js
var app = getApp()
Page({
	data: {
		items: [
			{
				icon: '../../images/iconfont-order.png',
				text: '我的订单',
				path: '../order/order'
			},
			{
				icon: '../../images/iconfont-addr.png',
				text: '收货地址',
				path: '../order/orderInfo'
			},
			{
				icon: '../../images/iconfont-kefu.png',
				text: '联系畅久客服',
				path: '18521708248',
			},
			{
				icon: '../../images/iconfont-help.png',
				text: 'QQ咨询',
				path: '3726721',
			},
		],
		settings: [
			{
				icon: '../../images/iconfont-about.png',
				text: '关于我们',
				path: '../about/about'
			},
		],
		userInfo: {
			avatarUrl: '',
			nickName: ''
		},
	},
	onLoad: function (options) {
		var that = this
		console.log("userInfo", app.globalData.userInfo)
		that.setData({ userInfo: app.globalData.userInfo })
		if (app.globalData.token) {
			profile.postCustomerInfo({}, that.infoCallback)
		} else {
			var token = wx.getStorageSync('userToken')
			if (token) {
				app.globalData.token = token
				profile.postCustomerInfo({}, that.infoCallback)
			}
		}
	},
	//分层级的switch跳转
	run(e) {
		const index = e.currentTarget.dataset.index
		const path = e.currentTarget.dataset.path
		switch (index) {
			case 0:
				wx.switchTab({
					url: `${path}`
				})
				break
			case 2: break
			case 3: break
			default:
				wx.navigateTo({
					url: `${path}`
				})
		}
	},

	bindtap(e) {
		const path = e.currentTarget.dataset.path
		wx.navigateTo({
			url: `${path}`
		})

	},

	logout() {
		wx.showModal({
			title: '友情提示',
			content: '确定要登出吗？',
			success: function (res) {
				if (res.confirm) {
					wx.switchTab({
						url: `../mine/mine`
					})
				}
			}
		})

	},
})